<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateSaleOrdersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('sale_orders', function (Blueprint $table) {
            $table->increments('id');
            $table->string('order_no',100)->unique()->comment('销售订单号');
            $table->integer('customer_id')->unsigned()->default(0)->comment('客户ID');
            $table->integer('shop_id')->unsigned()->default(0)->comment('店铺ID');
            $table->integer('machine_id')->unsigned()->default(0)->comment('机器ID');
            $table->integer('user_id')->unsigned()->default(0)->index()->comment('操作人员ID');
            $table->decimal('total_sale_price',8,2)->default(0.00)->unsigned()->comment('销售订单总价');
            $table->decimal('total_cost_price',8,2)->default(0.00)->unsigned()->comment('订单成本总价');
            $table->tinyInteger('status')->default(1)->unsigned()->comment('支付状态 1-待支付，2-已支付');
            $table->timestamps();
        });
        \DB::statement("ALTER TABLE `sale_orders` comment '销售订单表'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('sale_orders');
    }
}
